package org.xiaoyu.rpc.seralization.support;


import com.alibaba.fastjson.JSON;
import org.xiaoyu.rpc.seralization.Serializer;

import java.util.ArrayList;
import java.util.List;

/**
 * Created By Have
 * 2021/7/5 13:43
 */
public class JSONSerializer implements Serializer {
    @Override
    public int getSerializerAlgorithm() {
        return SerializerAlgorithm.FASTJSON.getType();
    }

    @Override
    public byte[] serializer(Object obj) {
        return JSON.toJSONBytes(obj);
    }

    @Override
    public <T> T deserializer(Class<T> clazz, byte[] bytes) {
        return JSON.parseObject(bytes, clazz);
    }

}
